package com.ywf.corebase.framework.init;

import com.ywf.corebase.framework.entity.User;
import com.ywf.corebase.framework.redis.RedisCache;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 /**
 * APP系统参数初始化加载
 *
 * @Author YWF
 * @Date 2021/3/21 21:48
 */
@Component
@Order(0)
public class AppInit implements CommandLineRunner {

    private final static Logger logger = LoggerFactory.getLogger(AppInit.class);

    @Autowired
    private RedisCache redisCache;

    @Override
    public void run(String... args) throws Exception {
        String key = "ss:001";
        redisCache.deleteObject(key);
        User user = new User();
        user.setAccountTel("18763734343");
        user.setNickName("张丰");
        user.setUserId(4534);
        List<User> dataList = new ArrayList();
        dataList.add(user);
        redisCache.setCacheList(key,dataList);
        logger.info("===============================APP参数初始化完成=============================");
        List list = redisCache.getCacheList(key);
        logger.info("redis获取到的数据："+list);
    }
}
